package com.when.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class InternetConnection {

	Context context;
	
	InternetConnection(Context context){
		this.context = context;
	}
	
	public boolean checkInternetConnection(){
		
		ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		
		if(connectivity != null) {
			
			NetworkInfo wifiInfo = connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
			NetworkInfo mobileInfo = connectivity.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
			if(!wifiInfo.isAvailable() && !mobileInfo.isAvailable()) {
				return false;
			}
			
		}
		return true;
	}
	
}
